package 乙级;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author mubei
 * @date 2021/8/20
 * @description
 */
public class 旧键盘 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String source = scanner.next().toUpperCase();
        String res = scanner.next().toUpperCase();
        String result = "";
        char[] chars = source.toCharArray();
        char[] chars1 = res.toCharArray();
        int index = 0;

        int i=0;
        for (; i < chars.length; i++) {
            while(chars1[index]!=chars[i]){
                if(result.indexOf(chars[i])==-1){
                    result+=chars[i];
                }
                i++;
            }
            index++;
            if(index >= chars1.length){
                i++;
                for(;i<chars.length;i++){
                    if(result.indexOf(chars[i])==-1){
                        result+=chars[i];
                    }
                }
            }
        }

        System.out.println(result);
    }


    public void solition(){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            char[] ch = sc.nextLine().toCharArray();
            String str = sc.nextLine();
            ArrayList<Character> lt = new ArrayList<>();
            for(int i=0;i<ch.length;i++){
                String c = String.valueOf(ch[i]);
                if(!str.contains(c)){
                    if(ch[i]>='a' && ch[i]<='z'){
                        ch[i]=(char)(ch[i]-32);
                    }
                    if(!lt.contains(ch[i])){
                        lt.add(ch[i]);
                    }
                }
            }
            for(Character cc : lt){
                System.out.print(cc);
            }
        }

    }
}
